package com.wwj.mapper;

import com.wwj.pojo.Department;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

//部门Dao
@Repository
public class DepartmentDao {
    //模拟数据库中的数据
    private static Map<Integer, Department> departments = null;
    static {
        departments = new HashMap<>();  //创建一个部门表
        departments.put(101, new Department(101,"测试部"));
        departments.put(102, new Department(102,"产品部"));
        departments.put(103, new Department(103,"研发部"));
        departments.put(104, new Department(104,"设计部"));
        departments.put(105, new Department(105,"运营部"));

    }

    //获取部门信息
    public Collection<Department> getDepartments(){
        return departments.values();
    }

    //通过id获取部门
    public Department getDepartmentsById(Integer id){
        return departments.get(id);
    }

}
